package gxwl.config;

import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import gxwl.common.constant.HeaderConstants;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.mybatis.spring.annotation.MapperScan;
import org.springdoc.core.GroupedOpenApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.info.InfoEndpoint;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * Swagger配置<br>
 * 访问地址：
 * <p><a href="/swagger-ui.html">/swagger-ui.html</a></p>
 *
 * @author jiangwh
 */
@Configuration
public class SwaggerConfig {

    /**
     * Swagger文档配置
     */
    @Bean
    public OpenAPI openApi() {
        return new OpenAPI()
                .info(new Info()
                        .title("接口文档")
                        .description("")
                        .version("1.0"))
                .components(new Components()
                        .addSecuritySchemes(HeaderConstants.IV_USER, new SecurityScheme().type(SecurityScheme.Type.APIKEY).name(HeaderConstants.IV_USER).in(SecurityScheme.In.HEADER))
                )
                .addSecurityItem(new SecurityRequirement().addList(HeaderConstants.IV_USER));
    }

}